﻿$(document).ready(function(){
	$("#comment-form").before("<div id='node-starrate'>Tổng quan:<div class='star-general'></div>Giao diện:<div class='star-gui'></div>Tính năng:<div class='star-feature'></div>Nội dung:<div class='star-content'></div></div>");
	
	$('#node-starrate .star-general').raty({
		path:'/5desire/sites/all/themes/push/images/stars/',
		starOn: 'star-on.png',
		starOff: 'star-off.png',
		onClick: function(score){
			Drupal.settings.note_settings.starRateGeneral = score;
		}
	});
	
	$('#node-starrate .star-gui').raty({
		path:'/5desire/sites/all/themes/push/images/stars/',
		starOn: 'star-on.png',
		starOff: 'star-off.png',
		onClick: function(score){
			Drupal.settings.note_settings.starRateGui = score;
		}
	});
	
	$('#node-starrate .star-feature').raty({
		path:'/5desire/sites/all/themes/push/images/stars/',
		starOn: 'star-on.png',
		starOff: 'star-off.png',
		onClick: function(score){
			Drupal.settings.note_settings.starRateFeature = score;
		}
	});
	
	$('#node-starrate .star-content').raty({
		path:'/5desire/sites/all/themes/push/images/stars/',
		starOn: 'star-on.png',
		starOff: 'star-off.png',
		onClick: function(score){
			Drupal.settings.note_settings.starRateContent = score;
		}
	});
	
	$("#comment-form").submit(function(){
		var starGen = Drupal.settings.note_settings.starRateGeneral;//parseInt($("#node-starrate .star-general").html(),10);
		var starGui = Drupal.settings.note_settings.starRateGui;//parseInt($("#node-starrate .star-gui").html(),10);
		var starFea = Drupal.settings.note_settings.starRateFeature;//parseInt($("#node-starrate .star-feature").html(),10);
		var starCon = Drupal.settings.note_settings.starRateContent;//parseInt($("#node-starrate .star-content").html(),10);
		
		var nid = Drupal.settings.note_settings.nid;
		var url = "starrate/node/" + nid.toString() + "/" + starGen + "/" + starGui + "/" + starFea + "/" + starCon;

		$.ajax({
				type: "GET",
				url: url
			});			
	});
});